// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from './common/js/http'
import moment from 'moment'
import {getDateDiff, Format} from './common/js/time'
import VueLazyLoad from 'vue-lazyload'
import 'lib-flexible/flexible.js'
import './common/sass/index'
import { dateFormat } from 'vux'

Vue.prototype.$http = axios

Vue.config.productionTip = false

const FastClick = require('fastclick')
FastClick.attach(document.body)

Vue.use(VueLazyLoad, {
  loading: '../static/imgDefault.png'
})

moment.lang('zh-cn')

Vue.filter('dateFmt', (input, dateFmtString) => {
  const lastFmtString = dateFmtString || 'YYYY-MM-DD HH:mm:ss'
  return moment(input).format(lastFmtString)
})

Vue.filter('datego', (input) => {
  return moment(input).startOf('minite').fromNow()       // 14 分钟前
})
// moment("20111031", "YYYYMMDD").fromNow(); // 6 年前
// moment("20120620", "YYYYMMDD").fromNow(); // 6 年前
// moment().startOf('day').fromNow();        // 13 小时前
// moment().endOf('day').fromNow();          // 11 小时内

Vue.filter('date', (input) => {
  return getDateDiff(input)
})

Vue.filter('dateFmtt', (time, fmt) => {
  return Format(time, fmt)
})
Vue.filter('dateVux', (time) => {
  return dateFormat(time, 'YYYY-MM-DD HH:mm')
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {App}
})
